appServices.factory('loginModule', function ($q, $http, md5, HostConfig, Common,Logger,ionPlugins,ionNative) {
    /*================== 登录模块 ====================*/
    //在服务中要打印东西需要return：例如：return console.log('123');但是这样打印会照成后面js无法执行，直接return出去，所以，建议一次打印一行；
    var api = HostConfig.getAPI();
    var url = api;
    // return console.log(api);
    return {
        // 登录快捷登录；
        login: function (mobile,code) {
            var deferred = $q.defer();
            $http({
                method: 'POST',
                url: url + '/checkCode',
                params: {
                    m_phone:mobile,
                    code:code
                },
                skipAuthorization: true
            }).success(function (succ) {
                deferred.resolve(succ);
            }).error(function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        },
        // 常规登录
        n_login: function (mobile,pwd) {
            var deferred = $q.defer();
            $http({
                method: 'POST',
                url: url + '/memberLogin',
                params: {
                    m_phone:mobile,
                    m_pass:pwd
                },
                skipAuthorization: true
            }).success(function (succ) {
                deferred.resolve(succ);
            }).error(function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        },
        // 注册服务
        register: function (params) {
            var deferred = $q.defer();
            $http({
                method: 'POST',
                url: url + '/registerCheckCode',
                params:params,
                skipAuthorization: true
            }).success(function (succ) {
                deferred.resolve(succ);
            }).error(function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        },
        //获取验证码服务快捷登录；
        get_captcha: function(mobile,area) {
            var deferred = $q.defer();
            $http({
                method: 'POST',
                url: url + '/sendValidCode?m_phone='+mobile+'&area'+area,
                headers: {
                    'Content-Type': 'application/json',
                    'appKey': "958ce0a62c344546a9111cbbfbf15c01"
                }
            }).success(function (success) {
                deferred.resolve(success);
            }).error(function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        },
        //注册验证码服务
        reg_captcha: function(mobile,area) {
            var deferred = $q.defer();
            $http({
                method: 'POST',
                url: url + '/registerSendCode?m_phone='+mobile+'&area'+area,
                headers: {
                    'Content-Type': 'application/json',
                    'appKey': "958ce0a62c344546a9111cbbfbf15c01"
                }
            }).success(function (success) {
                deferred.resolve(success);
            }).error(function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        }
    }
});